package com.per.mybootall.controller;

import com.per.mybootall.dao.UserMapper;
import com.per.mybootall.pojo.Order;
import com.per.mybootall.pojo.Product;
import com.per.mybootall.pojo.User;
import com.per.mybootall.service.AdminDoInter;
import com.per.mybootall.vo.ProductCarVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("admin")
public class AdminController {
@Autowired
private AdminDoInter adminDoInter;
@Autowired
private UserMapper userMapper;
    /*页面加载事件请求的对应的类别的数据
    *           productKind=====>>>>种类
    * */
    @PostMapping("/loadSomeMessage")
    public Map<Object,Object> rootLoadForMessage(String roottoken, String whoareroot, String productKind){
        return adminDoInter.adminLoad(roottoken,whoareroot,productKind);
    }

    @PostMapping("/orderLoadMessage")
    public Map<String,Object> OrderLoadMessage(String roottoken,String whoareroot){
        return adminDoInter.orderLoadMessage(roottoken,whoareroot);
    }

    @PostMapping("/loadUserMessage")
    public Map<String,Object> loadUserMessage(String roottoken,String whoareroot){
        return adminDoInter.loadUserMessage(roottoken,whoareroot);
    }




    @PostMapping("/delectUserMessage")
    public String delectUserMessage(Integer id){

        return adminDoInter.delectUserMessage(id);
    }

    @PostMapping("/delectProductMessage")
    public String delectProductMessage(Integer id){
        return adminDoInter.delectProductMessgae(id);
    }

    @PostMapping("/delectOrderMessage")
    public String delectOrderMessage(Integer id){
        return adminDoInter.delectProductMessgae(id);
    }



    @PostMapping("/updataProductMessage")
    public String updataProductMessage(String subtitle , BigDecimal prick, Integer stock,long id) {
        System.out.println("product====>>>>>"+subtitle+","+prick+","+stock+","+id);
        return adminDoInter.updateProductMessage(subtitle,prick,stock,id);

    }

    @PostMapping("/updataUserMessage")
    public String updataUserMessage(User user){
        return  adminDoInter.updateUserMessage(user);
    }

    @PostMapping("/updataOrderMessage")
    public String updataOrderMessage(Order order){
        return adminDoInter.updateOrderMessage(order);
    }



}
